package com.itheima.health.service.impl;

import com.itheima.health.common.RocketMQConst;
import com.itheima.health.message.SmsTask;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

@Slf4j
@DubboService
public class SmsServiceImpl implements SmsService {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Override
    public boolean sendphoneMessage(String businessType, String phone, String context) {
        // 短信内容敏感，生产环境下不要输出到日志里
        log.info("[发送短信]businessType:{},phone:{}", businessType, phone, context);
        // 封装成短信发送任务，放入MQ
        try {
            //rocketMQTemplate.convertAndSend(RocketMQConst.TOPIC_SMS_SEND, new SmsTask(businessType, phone, String.valueOf(context)));
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
